package com.example.SpringBootMybatis.mapper;

import com.example.SpringBootMybatis.entity.Admin;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface AdminMapper {

    @Select("select * from admin where name = #{name} limit 1")
    Admin findByName(@Param("name") String name);

    @Select("select * from admin where name = #{name} and password = #{password} limit 1")
    Admin findByNameAndPassword(@Param("name") String name, @Param("password") String password);

    @Insert("INSERT INTO admin (name, password) VALUES (#{admin.name}, #{admin.password})")
    void insertAdmin(@Param("admin") Admin admin);

}
